﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Montezuma
{
    class PlataformaMovimento
    {
        Texture2D textura;
        public Vector2 posicao;
        public Rectangle retangulo;
        int largura;
        public Vector2 direcao;
        public int posicaoInicial;
        public int posicaoFinal;

        public PlataformaMovimento(Texture2D textura, Vector2 posicao, int largura, int posicaoInicial, int posicaoFinal)
        {
            this.textura = textura;
            this.posicao = posicao;
            this.largura = largura;
            this.posicaoInicial = posicaoInicial;
            this.posicaoFinal = posicaoFinal;
            direcao = new Vector2(1, 0);
        }

        public void Update()
        {
            posicao += direcao;

            if (posicao.X >= posicaoFinal - largura)
            {
                direcao.X = -1;
            }

            if (posicao.X <= posicaoInicial)
            {
                direcao.X = 1;
            }

            retangulo = new Rectangle((int)posicao.X, (int)posicao.Y, largura, 15);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(textura, retangulo, new Rectangle(0, 0, textura.Width, textura.Height), Color.Green);
        }
    }
}
